package com.cloudcross.ssp.base.dao;

import java.io.Serializable;
import java.util.List;

import org.mybatis.spring.support.SqlSessionDaoSupport;

import com.cloudcross.ssp.common.form.MainForm;

/**
 * MyBatis框架Dao模板类。
 * 
 * @author 杜武强
 */
public class GenericIBatisDao extends SqlSessionDaoSupport {

    public void save(String key, Object object) {
        getSqlSession().insert(key, object);
    }

    public void delete(String key, Serializable id) {
        getSqlSession().delete(key, id);
    }

    public void delete(String key, Object object) {
        getSqlSession().delete(key, object);
    }

    public <T> T get(String key, Object params) {
        return (T) getSqlSession().selectOne(key, params);
    }

    public <T> List<T> getList(String key) {
        return getSqlSession().selectList(key);
    }

    public <T> List<T> getList(String key, Object params) {
        return getSqlSession().selectList(key, params);
    }

    public int count(String key, MainForm form) {
        return getSqlSession().selectOne(key, form);
    }

    public int listCount(String key, MainForm form) {
        return getSqlSession().selectOne(key, form);
    }
}